<?php
	/**
	 * @author Matthew Lieder
	 * @version 1.0
	 */
	class QExtGridColumn extends QBaseClass {
		// APPEARANCE
		protected $intWidth;
		protected $blnHidden;
		
		// BEHAVIOR
		protected $objOrderByClause = null;
		protected $objReverseOrderByClause = null;
		protected $blnEditable = true;

		// MISC
		protected $strName;
		protected $strHeader;
		protected $strHtml;
		protected $strRenderer;
		protected $strEditor;
		protected $strType;
		protected $strDateFormat;

		public function __construct($strName, $strHeader = null, $strHtml = null, $objOverrideParameters = null) {
			$this->strName = $strName;
			$this->strHeader = $strHeader;
			$this->strHtml = $strHtml;
			
			if($this->strHtml === null)
				$this->strHtml = '<?= $_ITEM->' . $this->strName . ' ?>';

			$objOverrideArray = func_get_args();
			if (count($objOverrideArray) > 3)
				try {
					unset($objOverrideArray[0]);
					unset($objOverrideArray[1]);
					unset($objOverrideArray[2]);
					$this->OverrideAttributes($objOverrideArray);
				} catch (QCallerException $objExc) {
					$objExc->IncrementOffset();
					throw $objExc;
				}
		}
		
		/////////////////////////
		// Public Properties: GET
		/////////////////////////
		public function __get($strName) {
			switch ($strName) {
				// APPEARANCE
				case "Width": return $this->intWidth;
				case "Hidden": return $this->blnHidden;
				
				// BEHAVIOR
				case "OrderByClause": return $this->objOrderByClause;
				case "ReverseOrderByClause": return $this->objReverseOrderByClause;

				// MISC
				case "Html": return $this->strHtml;
				case "Header": return $this->strHeader;
				case "Name": return $this->strName;
				case "Renderer": return $this->strRenderer;
				case "Editor": return $this->strEditor;
				case "Type": return $this->strType;
				case "DateFormat": return $this->strDateFormat;

				default:
					try {
						return parent::__get($strName);
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
			}
		}

		/////////////////////////
		// Public Properties: SET
		/////////////////////////
		public function __set($strName, $mixValue) {
			switch ($strName) {
				// APPEARANCE
				case "Width":
					try {
						$this->intWidth = QType::Cast($mixValue, QType::Integer);
						break;
					} catch (QInvalidCastException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
				case "Hidden":
					try {
						$this->blnHidden = QType::Cast($mixValue, QType::Boolean);
						break;
					} catch (QInvalidCastException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
					
					
				// BEHAVIOR
				case "OrderByClause":
					try {
						$this->objOrderByClause = QType::Cast($mixValue, 'QQOrderBy');
						break;
					} catch (QInvalidCastException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
				case "ReverseOrderByClause":
					try {
						$this->objReverseOrderByClause = QType::Cast($mixValue, 'QQOrderBy');
						break;
					} catch (QInvalidCastException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
					
					
				// MISC
				case "Html":
					try {
						$this->strHtml = QType::Cast($mixValue, QType::String);
						break;
					} catch (QInvalidCastException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
				case "Header":
					try {
						$this->strHeader = QType::Cast($mixValue, QType::String);
						break;
					} catch (QInvalidCastException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
				case "Name":
					try {
						$this->strName = QType::Cast($mixValue, QType::String);
						break;
					} catch (QInvalidCastException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
				case "Renderer":
					try {
						$this->strRenderer = QType::Cast($mixValue, QType::String);
						break;
					} catch (QInvalidCastException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
				case "Editor":
					try {
						$this->strEditor = QType::Cast($mixValue, QType::String);
						break;
					} catch (QInvalidCastException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
				case "Type":
					try {
						$this->strType = QType::Cast($mixValue, QType::String);
						break;
					} catch (QInvalidCastException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
				case "DateFormat":
					try {
						$this->strDateFormat = QType::Cast($mixValue, QType::String);
						break;
					} catch (QInvalidCastException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}															
					
				default:
					try {
						parent::__set($strName, $mixValue);
						break;
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
			}
		}
	}
?>